#ifndef __TX_MEMORY_H_
#define __TX_MEMORY_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include <stdio.h>
#include <string.h>
#include <stdint.h>


typedef struct
{
    /* Define the byte pool ID used for error checking.  字节内存池id */
    // unsigned long       tx_byte_pool_id;  // 可以不使用

    /* Define the byte pool's name.  字节内存池名字 */
    // char                *tx_byte_pool_name;

    /* Define the number of available bytes in the pool.  字节内存池可分配字节 */
    unsigned long tx_byte_pool_available;

    /* Define the number of fragments in the pool.  字节内存池块个数 */
    unsigned int tx_byte_pool_fragments;

    /* Define the head pointer of byte pool.  字节内存池头list指针 */
    unsigned char *tx_byte_pool_list;

    /* Define the search pointer used for initial searching for memory
       in a byte pool.  字节内存池开始搜索起始地址 */
    unsigned char *tx_byte_pool_search;

    /* Save the start address of the byte pool's memory area.  字节内存池所在内存空间起始地址 */
    unsigned char *tx_byte_pool_start;

    /* Save the byte pool's size in bytes.  字节内存池大小 */
    unsigned long tx_byte_pool_size;

    /* Define the created list next and previous pointers.  */
    // struct TX_BYTE_POOL_STRUCT_USER
    //                                 *tx_byte_pool_created_next,          //指向下一个字节内存池指针
    //                                 *tx_byte_pool_created_previous;      //指向前一个字节内存池指针

} TX_BYTE_POOL_OBJ;


/* export func */

int _tx_byte_pool_create(TX_BYTE_POOL_OBJ *pool_ptr, void *pool_start, uint32_t pool_size);
int _tx_byte_allocate( TX_BYTE_POOL_OBJ *pool_ptr, void **memory_ptr, uint32_t memory_size);
int _tx_byte_release(TX_BYTE_POOL_OBJ *pool_ptr, void *memory_ptr);


#ifdef __cplusplus
}
#endif

#endif // __TX_MEMORY_H_
